﻿<UserControl x:Class="Srk.BetaseriesApiApp.Controls.TimelineControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <WrapPanel Orientation="Horizontal">
            <ToggleButton IsChecked="{Binding IsAutoRefreshing}" Margin="4">Auto refresh</ToggleButton>
            <Button Command="{Binding RefreshCommand}" Margin="4">Refresh</Button>
            <Button Command="{Binding ClearCommand}" Margin="4">Clear</Button>
        </WrapPanel>

        <WrapPanel Orientation="Horizontal" Grid.Row="1">
            <TextBlock Margin="4">Filters: </TextBlock>
            <ComboBox Margin="4"
                      ItemsSource="{Binding Types}"
                      SelectedItem="{Binding SelectedType, Mode=TwoWay}" />
        </WrapPanel>

        <ScrollViewer Grid.Row="3">
            <ItemsControl ItemsSource="{Binding ItemsCV}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border BorderBrush="Gray" BorderThickness="1" Padding="4" Margin="1">
                            <Border.Background>
                                <LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1">
                                    <GradientStop Color="LightGray" Offset="0" />
                                    <GradientStop Color="White" Offset=".05" />
                                    <GradientStop Color="#ffC7D5EA" Offset="1" />
                                </LinearGradientBrush>
                            </Border.Background>
                            <Grid Width="280">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <TextBlock Grid.ColumnSpan="2" Margin="4"
                                           Text="{Binding Type}"
                                           TextAlignment="Center" />

                                <TextBlock Grid.Row="1" Margin="4"
                                           Text="{Binding Username}" FontWeight="Bold" />

                                <TextBlock Grid.Row="1" Grid.Column="1"  Margin="4"
                                           Text="{Binding Date}" />

                                <TextBlock Grid.Row="2" Grid.ColumnSpan="2"  Margin="4"
                                           Text="{Binding Message}"
                                           TextWrapping="Wrap"
                                           FontStyle="Italic" />

                                <TextBlock Grid.Row="4" Grid.ColumnSpan="2"  Margin="4"
                                           Text="{Binding ReferenceEpisode.Title}" />

                                <TextBlock Grid.Row="3" Grid.Column="1"  Margin="4"
                                           Text="{Binding ReferenceEpisode.Number}" FontWeight="Bold" />

                                <TextBlock Grid.Row="3" Grid.Column="0"  Margin="4"
                                           Text="{Binding ReferenceEpisode.ShowName}"
                                           TextWrapping="WrapWithOverflow" FontWeight="Bold" />
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
        
        <TextBlock Grid.Row="4" Text="{Binding StatusMessage}" Margin="4" />
    </Grid>
</UserControl>
